package org.example.batch;

import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import groovyjarjarantlr4.v4.runtime.misc.NotNull;
import groovyjarjarantlr4.v4.runtime.misc.Nullable;

import javax.swing.*;

public class SqlResultGutterIconFix implements LocalQuickFix {
    private final boolean success;

    public SqlResultGutterIconFix(boolean success) {
        this.success = success;
    }

    @Override
    public @NotNull String getName() {
        return success ? "SQL 执行成功" : "SQL 执行失败";
    }

    @Override
    public @NotNull String getFamilyName() {
        return "SQL 执行状态";
    }

    @Override
    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
        // 无操作（只用于显示图标）
    }

    // ✅ 关键：提供 gutter 图标
    public @Nullable Icon getIcon() {
        return success ? AllIcons.General.InspectionsOK : AllIcons.General.Error;
    }
}